﻿<phone:PhoneApplicationPage          
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:krempel="clr-namespace:Krempel.WP7.Core.Controls;assembly=Krempel.WP7.Core"  
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"                            
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:mycontrols="clr-namespace:AzureTracer.Views.Controls"
    xmlns:myConvertes="clr-namespace:AzureTracer.Views.Converters"
    xmlns:myviews="clr-namespace:AzureTracer.Views"
    xmlns:myBehaviors="clr-namespace:AzureTracer.Views.Behaviors" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"                                                        
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:MvvmLight="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP71" 
    xmlns:my="clr-namespace:AzureTracer.Views.Controls" 
    xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    
    xmlns:System="clr-namespace:System;assembly=mscorlib" 
    xmlns:eim="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions" 
    x:Class="AzureTracer.Views.MainPage"
    x:Name="phoneApplicationPage" 
    
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"        
    shell:SystemTray.IsVisible="True"
    toolkit:TiltEffect.IsTiltEnabled="True"
    DataContext="{Binding Main, Source={StaticResource Locator}}">

    <phone:PhoneApplicationPage.Resources>

        <myConvertes:HighlightSearchConverter x:Key="HighlightConverter"/>
        <myConvertes:BoolToColorConverter x:Key="BoolToColorConverter"/>
        <myConvertes:IntToLevelImageSourceConverter x:Key="IntToLevelImageSourceConverter"/>
        <myConvertes:IntToTraceFromStringConverter x:Key="IntToTraceFromStringConverter"/>

        <DataTemplate x:Name="LogItemTemplate">
            <Grid 
                x:Name="ListItemGrid" 
                Margin="0,0,34,12"  
                Tap="ListItemGrid_Tap">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>

                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="90"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock
                        x:Name="textBlockRole"
                        Grid.Column="0"
                        Margin="8,0,0,0"
                        Text="{Binding Role}" 
                        Foreground="{Binding DataContext.SearchActive, ConverterParameter={StaticResource PhoneSubtleBrush}, Converter={StaticResource BoolToColorConverter}, ElementName=LayoutRoot}"
                        Style="{StaticResource PhoneTextLargeStyle}" 
                        VerticalAlignment="Center" FontSize="34.667" 
                        FontFamily="Segoe WP Semibold"/>
                    <TextBlock 
                        x:Name="textBlockTime"               
                        Grid.Column="1"
                        Text="{Binding Timestamp, Converter={StaticResource HourlyDateTimeConverter}}" 
                        Foreground="{Binding DataContext.SearchActive, ConverterParameter={StaticResource PhoneSubtleBrush}, Converter={StaticResource BoolToColorConverter}, ElementName=LayoutRoot}"
                        Style="{StaticResource PhoneTextNormalStyle}" 
                        VerticalAlignment="Center" TextAlignment="Right"
                        FontFamily="Segoe WP Semibold" 
                        TextWrapping="Wrap"/>
                </Grid>
                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="40"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock 
                    		x:Name="textBlockMessage"  
                    		Grid.Column="0"                        
                    		Style="{StaticResource PhoneTextSubtleStyle}" 
                    		myviews:MainPage.Inlines="{Binding VisibleMessage, Converter={StaticResource HighlightConverter}}" />
                    <Image 
                        Grid.Column="1"
                        Margin="0,-4,0,0"
                        Height="38" Width="38"  
                        VerticalAlignment="Top" HorizontalAlignment="Center"  
                        Source="{Binding Level, Converter={StaticResource IntToLevelImageSourceConverter}}"/>
                </Grid>

                <Grid.Resources>
                    <Storyboard x:Name="UnloadItemStoryboard">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="ListItemGrid">
                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="400">
                                <EasingDoubleKeyFrame.EasingFunction>
                                    <CubicEase EasingMode="EaseInOut"/>
                                </EasingDoubleKeyFrame.EasingFunction>
                            </EasingDoubleKeyFrame>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ListItemGrid">
                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0">
                                <EasingDoubleKeyFrame.EasingFunction>
                                    <CubicEase EasingMode="EaseInOut"/>
                                </EasingDoubleKeyFrame.EasingFunction>
                            </EasingDoubleKeyFrame>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </Grid.Resources>
                <Grid.RenderTransform>
                    <CompositeTransform/>
                </Grid.RenderTransform>

                <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu>
                        <toolkit:MenuItem 
                            Header="{Binding Labels.Delete, Source={StaticResource LabelsManager}}" 
                            Command="{Binding Main.DeleteCommand, Source={StaticResource Locator}}" 
                            CommandParameter="{Binding}" 
                            Click="DeleteMenuItem_Click"
                            Foreground="Black"/>
                        <toolkit:MenuItem 
                            Header="{Binding Labels.AsRead, Source={StaticResource LabelsManager}}"  
                            Command="{Binding Main.SetAsReadCommand, Source={StaticResource Locator}}" 
                            CommandParameter="{Binding}"
                            Visibility="{Binding IsRead, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}" 
                            Foreground="Black" />
                        <toolkit:MenuItem 
                            Header="{Binding Labels.AsUnread, Source={StaticResource LabelsManager}}" 
                            Command="{Binding Main.SetAsUnreadCommand, Source={StaticResource Locator}}" 
                            CommandParameter="{Binding}" 
                            Visibility="{Binding IsRead, Converter={StaticResource VisibilityConverter}}"
                            Foreground="Black"/>
                    </toolkit:ContextMenu>
                </toolkit:ContextMenuService.ContextMenu>

                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Tap">
                        <i:InvokeCommandAction Command="{Binding Main.SelectCommand, Source={StaticResource Locator}}" CommandParameter="{Binding}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <i:Interaction.Behaviors>
                    <ec:DataStateBehavior Binding="{Binding IsRead}" Value="True" TrueState="Read" FalseState="Unread"/>
                </i:Interaction.Behaviors>

                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="ReadGroup">
                        <VisualStateGroup.Transitions>
                            <VisualTransition GeneratedDuration="0"/>
                        </VisualStateGroup.Transitions>
                        <VisualState x:Name="Read"/>
                        <VisualState x:Name="Unread">
                            <Storyboard>
                                <ColorAnimation 
                                    Duration="0" 
                                    To="{StaticResource PhoneAccentColor}" 
                                    Storyboard.TargetProperty="(Foreground).(Color)" 
                                    Storyboard.TargetName="textBlockMessage" 
                                    d:IsOptimized="True"/>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <VisualStateManager.CustomVisualStateManager>
                    <ec:ExtendedVisualStateManager/>
                </VisualStateManager.CustomVisualStateManager>

            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="TitleTemplate">
            <Border x:Name="Logo" CornerRadius="8" BorderThickness="0" BorderBrush="{StaticResource PhoneAccentBrush}" Margin="0,0,137,0">
                <StackPanel Orientation="Horizontal">
                    <Border BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50" Height="50" Padding="0" Margin="10,0,0,0">
                        <Border.Background>
                            <ImageBrush Stretch="Uniform" ImageSource="/Resources/Images/Cloud.png"/>
                        </Border.Background>
                    </Border>
                    <TextBlock HorizontalAlignment="Left" FontWeight="Bold" FontSize="26.667" 
                               Text="{Binding Labels.AppTitle, Source={StaticResource LabelsManager}}" 
                               VerticalAlignment="Center" Margin="10,0,0,0" />
                </StackPanel>
            </Border>
        </DataTemplate>

        <Style x:Name="PivotItemStyle" TargetType="controls:PivotItem">
            <Setter Property="Margin" Value="0,20,2,0"/>
        </Style>

    </phone:PhoneApplicationPage.Resources>

    <!--Transitions-->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:SlideTransition Mode="SlideLeftFadeIn"/>
            </toolkit:NavigationInTransition.Backward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <krempel:ItemTurnstileTransition XMode="ForwardOut" YMode="TopToBottom" />
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <controls:Pivot
            x:Name="PivotContent"
            TitleTemplate="{StaticResource TitleTemplate}"           
            SelectionChanged="GenericPivot_OnSelectionChanged">

            <controls:PivotItem               
                Header="{Binding Labels.All, Source={StaticResource LabelsManager}}" 
                Style="{StaticResource PivotItemStyle}">
                <Grid>
                    <toolkit:MultiselectList                         
                        SelectionChanged="SelectList_SelectionChanged"
                        IsSelectionEnabledChanged="SelectList_IsSelectionEnabledChanged"                                                
                        ItemsSource="{Binding AllLogs.View}"                 
                        ItemTemplate="{StaticResource LogItemTemplate}"                        
                        Visibility="{Binding AllLogs.View.IsEmpty, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}"/>

                    <!--Panels for 0 trace elements-->
                    <Grid                        
                        Margin="24,0,24,0"
                        Visibility="{Binding AllLogs.View.IsEmpty, Converter={StaticResource VisibilityConverter}}" >
                        <!--Panels for no serch-->
                        <StackPanel
                            Visibility="{Binding SearchActive, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}" >
                            <!--Never traces download-->
                            <StackPanel
                                Visibility="{Binding AppSettings.AnySyncEnding, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}">
                                <TextBlock 
                                    Text="{Binding Labels.NoAllTraces, Source={StaticResource LabelsManager}}" 
                                    TextWrapping="Wrap" 
                                    Style="{StaticResource PhoneTextGroupHeaderStyle}"/>
                                <HyperlinkButton 
                                    Content="{Binding Labels.NoAllTracesLink, Source={StaticResource LabelsManager}}"
                                    Click="Hyperlink_Click"
                                    Foreground="{StaticResource PhoneAccentBrush}" FontSize="32" />
                            </StackPanel>
                            <!--<no traces in xxx days panel-->
                            <StackPanel                  
                                Visibility="{Binding AppSettings.AnySyncEnding, Converter={StaticResource VisibilityConverter}}">
                                <TextBlock 
                                    Text="{Binding Labels.NoTracesIn, Source={StaticResource LabelsManager}}" 
                                    Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                                <TextBlock 
                                    Text="{Binding AppSettings.MaxDaysSync, Converter={StaticResource IntToTraceFromStringConverter}}"                                    
                                    Foreground="{StaticResource PhoneTextBoxForegroundBrush}"
                                    Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                            </StackPanel>
                        </StackPanel>
                        <!--No Search result panel-->
                        <StackPanel                            
                            Orientation="Horizontal"
                            Visibility="{Binding SearchActive, Converter={StaticResource VisibilityConverter}}" >
                            <TextBlock 
                                Text="{Binding Labels.NoResultsFor, Source={StaticResource LabelsManager}}" 
                                Style="{StaticResource PhoneTextGroupHeaderStyle}"/>
                            <TextBlock 
                                Margin="0"
                                Text="{Binding SearchText}" 
                                Foreground="{StaticResource PhoneTextBoxForegroundBrush}"
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                        </StackPanel>
                    </Grid>
                </Grid>
            </controls:PivotItem>
            <controls:PivotItem 
                Header="{Binding Labels.Error, Source={StaticResource LabelsManager}}" 
                Style="{StaticResource PivotItemStyle}">
                <Grid>
                    <toolkit:MultiselectList 
                        SelectionChanged="SelectList_SelectionChanged"
                        IsSelectionEnabledChanged="SelectList_IsSelectionEnabledChanged"
                        ItemsSource="{Binding ErrorLogs.View}"
                        ItemTemplate="{StaticResource LogItemTemplate}"
                        Visibility="{Binding ErrorLogs.View.IsEmpty, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}"/>

                    <!--Panels for 0 trace elements-->
                    <Grid                        
                        Margin="24,0,24,0"
                        Visibility="{Binding ErrorLogs.View.IsEmpty, Converter={StaticResource VisibilityConverter}}" >
                        <!--<no traces in xxx days panel-->
                        <StackPanel
                            Visibility="{Binding SearchActive, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}" >
                            <TextBlock 
                                Text="{Binding Labels.NoErrorTraces, Source={StaticResource LabelsManager}}" 
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                            <TextBlock
                                Text="{Binding AppSettings.MaxDaysSync, Converter={StaticResource IntToTraceFromStringConverter}}"                                    
                                Foreground="{StaticResource PhoneTextBoxForegroundBrush}"
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                        </StackPanel>
                        <!--No Search result panel-->
                        <StackPanel                            
                            Orientation="Horizontal"
                            Visibility="{Binding SearchActive, Converter={StaticResource VisibilityConverter}}" >
                            <TextBlock 
                                Text="{Binding Labels.NoResultsFor, Source={StaticResource LabelsManager}}" 
                                Style="{StaticResource PhoneTextGroupHeaderStyle}"/>
                            <TextBlock 
                                Margin="0"
                                Text="{Binding SearchText}" 
                                Foreground="{StaticResource PhoneTextBoxForegroundBrush}"
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                        </StackPanel>
                    </Grid>
                </Grid>
            </controls:PivotItem>
            <controls:PivotItem 
                Header="{Binding Labels.Warning, Source={StaticResource LabelsManager}}" 
                Style="{StaticResource PivotItemStyle}">
                <Grid>
                    <toolkit:MultiselectList 
                        SelectionChanged="SelectList_SelectionChanged"
                        IsSelectionEnabledChanged="SelectList_IsSelectionEnabledChanged"
                        ItemsSource="{Binding WarningLogs.View}" 
                        ItemTemplate="{StaticResource LogItemTemplate}"
                        Visibility="{Binding WarningLogs.View.IsEmpty, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}"/>

                    <!--Panels for 0 trace elements-->
                    <Grid                        
                        Margin="24,0,24,0"
                        Visibility="{Binding WarningLogs.View.IsEmpty, Converter={StaticResource VisibilityConverter}}" >
                        <!--<no traces in xxx days panel-->
                        <StackPanel
                            Visibility="{Binding SearchActive, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}" >
                            <TextBlock 
                                Text="{Binding Labels.NoWarningTraces, Source={StaticResource LabelsManager}}" 
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                            <TextBlock
                                Text="{Binding AppSettings.MaxDaysSync, Converter={StaticResource IntToTraceFromStringConverter}}"                                    
                                Foreground="{StaticResource PhoneTextBoxForegroundBrush}"
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                        </StackPanel>
                        <!--No Search result panel-->
                        <StackPanel                            
                            Orientation="Horizontal"
                            Visibility="{Binding SearchActive, Converter={StaticResource VisibilityConverter}}" >
                            <TextBlock 
                                Text="{Binding Labels.NoResultsFor, Source={StaticResource LabelsManager}}" 
                                Style="{StaticResource PhoneTextGroupHeaderStyle}"/>
                            <TextBlock 
                                Margin="0"
                                Text="{Binding SearchText}" 
                                Foreground="{StaticResource PhoneTextBoxForegroundBrush}"
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                        </StackPanel>
                    </Grid>
                </Grid>
            </controls:PivotItem>
            <controls:PivotItem 
                Header="{Binding Labels.Info, Source={StaticResource LabelsManager}}" 
                Style="{StaticResource PivotItemStyle}">
                <Grid>
                    <toolkit:MultiselectList 
                        SelectionChanged="SelectList_SelectionChanged"
                        IsSelectionEnabledChanged="SelectList_IsSelectionEnabledChanged"
                        ItemsSource="{Binding InfoLogs.View}" 
                        ItemTemplate="{StaticResource LogItemTemplate}"
                        Visibility="{Binding InfoLogs.View.IsEmpty, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}"/>

                    <!--Panels for 0 trace elements-->
                    <Grid                        
                        Margin="24,0,24,0"
                        Visibility="{Binding InfoLogs.View.IsEmpty, Converter={StaticResource VisibilityConverter}}" >
                        <!--<no traces in xxx days panel-->
                        <StackPanel
                            Visibility="{Binding SearchActive, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}" >
                            <TextBlock 
                                Text="{Binding Labels.NoInfoTraces, Source={StaticResource LabelsManager}}" 
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                            <TextBlock 
                                Text="{Binding AppSettings.MaxDaysSync, Converter={StaticResource IntToTraceFromStringConverter}}"                                    
                                Foreground="{StaticResource PhoneTextBoxForegroundBrush}"
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                        </StackPanel>
                        <!--No Search result panel-->
                        <StackPanel                            
                            Orientation="Horizontal"
                            Visibility="{Binding SearchActive, Converter={StaticResource VisibilityConverter}}" >
                            <TextBlock 
                                Text="{Binding Labels.NoResultsFor, Source={StaticResource LabelsManager}}" 
                                Style="{StaticResource PhoneTextGroupHeaderStyle}"/>
                            <TextBlock 
                                Margin="0"
                                Text="{Binding SearchText}" 
                                Foreground="{StaticResource PhoneTextBoxForegroundBrush}"
                                Style="{StaticResource PhoneTextGroupHeaderStyle}" />
                        </StackPanel>
                    </Grid>
                </Grid>
            </controls:PivotItem>

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <MvvmLight:EventToCommand Command="{Binding PivotSelectionChanged}" PassEventArgsToCommand="True"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>

        </controls:Pivot>

        <my:SearchControl 
            x:Name="searchControl" HorizontalAlignment="Left" Margin="10,5,0,0"  VerticalAlignment="Top"
            SearchCommand="{Binding SearchCommand}"  
            IsVisible="{Binding SearchActive, Mode=TwoWay}" 
            Width="458" Foreground="#FFFF0B0B" Opacity="0" >
            <my:SearchControl.RenderTransform>
                <CompositeTransform TranslateY="-100"/>
            </my:SearchControl.RenderTransform>
            <i:Interaction.Behaviors>
                <ec:DataStateBehavior Binding="{Binding SearchActive}" Value="true" TrueState="Search" FalseState="NoSearch"/>
            </i:Interaction.Behaviors>
        </my:SearchControl>

        <my:ProgressIndicatorProxy 
            IsIndeterminate="{Binding StateInfo.IsLoading}"  
            Text="{Binding StateInfo.Text}"  
            IsVisible="{Binding StateInfo.IsVisible}" />

        <my:BindableApplicationBar 
            x:Name="AppBar" >
            <my:BindableApplicationBar.MenuItems>
                <my:BindableApplicationBarMenuItem 
                    x:Name="AllReadMenuItem"
                    Command="{Binding AllAsReadCommand}" 
                    Text="{Binding Labels.AllAsRead, Source={StaticResource LabelsManager}}"
                    Visibility="{Binding IsLoading, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}"/>
                <my:BindableApplicationBarMenuItem 
                    x:Name="ReadMultipleMenuItem"
                    Text="{Binding Labels.AsRead, Source={StaticResource LabelsManager}}"
                    Click="DisableSelection_Click"
                    Command="{Binding SetAsReadMultipleCommand}"
                    CommandParameter="{Binding ActualMultiselectList.SelectedItems, ElementName=phoneApplicationPage}"
                    Visibility="Collapsed" />
                <my:BindableApplicationBarMenuItem 
                    x:Name="UnreadMultipleMenuItem"
                    Text="{Binding Labels.AsUnread, Source={StaticResource LabelsManager}}"
                    Click="DisableSelection_Click"
                    Command="{Binding SetAsUnreadMultipleCommand}"
                    CommandParameter="{Binding ActualMultiselectList.SelectedItems, ElementName=phoneApplicationPage}" 
                    Visibility="Collapsed" />
                <my:BindableApplicationBarMenuItem 
                    x:Name="SettingsMenuItem"
                    Text="{Binding Labels.Configuration, Source={StaticResource LabelsManager}}"
                    Click="DisableSelection_Click"
                    Command="{Binding ConfigurationCommand}"/>
            </my:BindableApplicationBar.MenuItems>
            <mycontrols:BindableApplicationBarIconButton 
                x:Name="SendMailMultipleIconButton"
                Click="EnableSelection_Click"  
                Command="{Binding SendEmailMultipleCommand}"
                CommandParameter="{Binding ActualMultiselectList.SelectedItems, ElementName=phoneApplicationPage}"                
                IconUri="/Resources/Images/appbar.feature.email.rest.png" 
                Text="{Binding Labels.SendMail, Source={StaticResource LabelsManager}}"
                Visibility="Collapsed"/>
            <my:BindableApplicationBarIconButton 
                x:Name="DeleteMultipleIconButton"
                Command="{Binding DeleteMultipleCommand}" 
                CommandParameter="{Binding ActualMultiselectList.SelectedItems, ElementName=phoneApplicationPage}"
                Click="DeleteMultiple_Click"
                IconUri="/Resources/Images/ApplicationBar.Delete.png" 
                Text="{Binding Labels.Delete, Source={StaticResource LabelsManager}}"
                Visibility="Collapsed"/>
            <my:BindableApplicationBarIconButton 
                x:Name="EnableSelectionIconButton"
                Click="EnableSelection_Click"                                                
                IconUri="/Resources/Images/ApplicationBar.Select.png" 
                Text="{Binding Labels.Select, Source={StaticResource LabelsManager}}"
                Visibility="{Binding StateInfo.IsLoading, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}"/>
            <my:BindableApplicationBarIconButton
                x:Name="RefreshIconButton"
                Command="{Binding RefreshCommnad}"                 
                IconUri="/Resources/Images/appbar.refresh.rest.png" 
                Text="{Binding Labels.Refresh, Source={StaticResource LabelsManager}}"
                Visibility="{Binding StateInfo.IsLoading, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}"/>
            <my:BindableApplicationBarIconButton 
                x:Name="SearchIconButton"
                Command="{Binding ShowSearchCommand}" 
                IconUri="/Resources/Images/appbar.feature.search.rest.png" 
                Text="{Binding Labels.Search, Source={StaticResource LabelsManager}}"
                Visibility="{Binding SearchActive, ConverterParameter=true, Converter={StaticResource VisibilityConverter}}"/>
        </my:BindableApplicationBar>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="SearchControlStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.8">
                        <VisualTransition.GeneratedEasingFunction>
                            <QuarticEase EasingMode="EaseOut"/>
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Search">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="searchControl" d:IsOptimized="True"/>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="searchControl" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="NoSearch"/>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <MvvmLight:EventToCommand Command="{Binding LoadedCommand}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>

</phone:PhoneApplicationPage>